//
//  HistoryNumberController.m
//  FactorySale
//
//  Created by 胡小康 on 2020/4/21.
//  Copyright © 2020 主事丫环. All rights reserved.
//

#import "HistoryNumberController.h"
#import "HistoryNumberCell.h"
#import "HistoryNumberModel.h"
@interface HistoryNumberController ()
@property (weak, nonatomic) IBOutlet UITableView *tableView;
@property (nonatomic,strong)NSMutableArray *listArray;
@end

@implementation HistoryNumberController

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [self.navigationController setNavigationBarHidden:NO animated:animated];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    [self setupUI];
    self.listArray = [NSMutableArray arrayWithCapacity:0];
    [self requestNumberOfHistoricalData];
}
- (void)requestNumberOfHistoricalData {
    
    NSMutableDictionary *param = [NSMutableDictionary dictionary];
    param[@"id"] = self.id;
    [NetWorkTool POST:appQrcodeHistory param:param success:^(id dic) {
        NSLog(@"%@",dic);
        self.listArray = [HistoryNumberModel mj_objectArrayWithKeyValuesArray:dic[@"data"]];
        
        [self.tableView reloadData];
        
    } other:^(id dic) {
        ShowToastWithText(dic[@"msg"]);
        
    } fail:^(NSError *error) {
        
    } needUser:NO];
    
}
- (void)setupUI{
    self.title = @"历史申请数量";
    [self.leftbutton setImage:imgname(@"left_icon") forState:(UIControlStateNormal)];
    self.view.backgroundColor = Main_BackGroundColor;
    
    self.tableView.rowHeight = 50;
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.tableView.tableFooterView = [[UIView alloc] init];
}
#pragma mark -- UITableViewDataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return self.listArray.count;
    
   
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    HistoryNumberCell *cell = [HistoryNumberCell cellWithTableView:tableView];
    cell.model = self.listArray[indexPath.row];
    return cell;
    
}
@end
